﻿var DomainUrl = top.location.hostname;
var AuthUrl = top.location.hostname;

$ = function(em) {
    if (document.getElementById){ return document.getElementById(em); }
    else if (document.all){ return document.all[em]; }
    else if (document.layers){ return document.layers[em]; }
    else{ return null; }
};
$F = function(em){	return document.getElementById(em).value;	};


function Trim(){
	return this.replace(/\s+$|^\s+/g,"");
}
String.prototype.Trim=Trim;

function getObjValues(id){
	if(getObjects(id).value!=undefined)
		return getObjects(id).value.Trim();
	else
		return "";
}

function getObjects(id) { 	
	if (document.getElementById) { 
		return document.getElementById(id); 
	} else if (document.all) { 
		return document.all[id]; 
	} else if (document.layers) { 
		return document.layers[id]; 
	} 
}


function createXMLHttpRequest(){
       	if (window.XMLHttpRequest) {//wwww.qianwe.com
		XMLHttpReq=new XMLHttpRequest();
	}else if (window.ActiveXObject) {//IE 浏览器
	     try {
			    XMLHttpReq=new ActiveXObject("Msxml2.XMLHTTP");
	     } catch (e) {
		        try{
					XMLHttpReq=new ActiveXObject("Micrsost.XMLHTTP");
				} catch(e){}
	     }
        }
}

var cache = new Array();
function getHttpObject() {
    var objType = false;
    try {
        objType = new ActiveXObject('Msxml2.XMLHTTP');
    } catch(e) {
        try {
            objType = new ActiveXObject('Microsoft.XMLHTTP');
        } catch(e) {
            objType = new XMLHttpRequest();
        }
    }
    return objType;
}

function showad(_id){
	var theHttpRequest = getHttpObject();
	theHttpRequest.onreadystatechange = function() {processAJAX();};
	theHttpRequest.open("GET", "inc/ajaxs.php?action=showad&id="+_id, true);
	theHttpRequest.send(null);
	function processAJAX(){
		if (theHttpRequest.readyState == 4) {
			if (theHttpRequest.status == 200) {
				document.getElementById("ad").innerHTML = unescape(theHttpRequest.responseText);
			} else {
				document.getElementById("ad").innerHTML = "载入失败";
			}
		}
	}
}

function showcount(){
	var theHttpRequest = getHttpObject();
	theHttpRequest.onreadystatechange = function() {processAJAX();};
	theHttpRequest.open("GET", "inc/ajaxs.php?action=showcount", true);
	theHttpRequest.send(null);
	function processAJAX(){
		if (theHttpRequest.readyState == 4) {
			if (theHttpRequest.status == 200) {
				document.getElementById("showcount").innerHTML = unescape(theHttpRequest.responseText);
			} else {
				document.getElementById("showcount").innerHTML = "载入失败";
			}
		}
	}
}

function ShowStar(level,ids){
	var htmlStr=""
	if(level==0){level=0}
	if (level>0){htmlStr+="<img src='img/starno.gif' border='0' style='cursor:pointer;margin-left:2px;' title='取消推荐' onclick='EditIsBest("+ids+",0)'/>"}
	for(i=1;i<=level;i++){
		htmlStr+= "<img src='img/star0.gif' border='0' style='cursor:pointer;margin-left:2px;' title='推荐为"+i+"星级' id='star"+ids+"_"+i+"' onclick='EditIsBest("+ids+","+i+")' />"
	}
	for(j=level+1;j<=5;j++){
		htmlStr+= "<img src='img/star1.gif' border='0' style='cursor:pointer;margin-left:2px;' title='推荐为"+j+"星级' id='star"+ids+"_"+j+"' onclick='EditIsBest("+ids+","+j+")' />"
	}
        document.getElementById("CD_IsBest"+ids).innerHTML = htmlStr;
}

function EditIsBest(_id,_l){
	 createXMLHttpRequest();
	 XMLHttpReq.open("GET", "inc/ajaxs.php?action=editisbest&id="+ _id +"&l="+ _l,true);
	 XMLHttpReq.onreadystatechange= function(){
		if(XMLHttpReq.readyState == 4){
			if(XMLHttpReq.status == 200){
				if(XMLHttpReq.responseText==1){
					ShowStar(_l,_id);
				}else{
					document.getElementById("CD_IsBest"+_id).innerHTML = "<font color='red'>提交失败</font>";		
				}
			}else alert("网络链接失败");
		}
	}
	XMLHttpReq.send(null);
}

function get_tags(parentobj, tag){
	if (typeof parentobj.getElementsByTagName != 'undefined'){ return parentobj.getElementsByTagName(tag);
	}else if (parentobj.all && parentobj.all.tags){ return parentobj.all.tags(tag);
	}else{ return new Array(); }
};

function clk(_act, _id) {
	var v = [];
	var a = get_tags($(_id), 'input');

	for (var i = 0; i < a.length; i++) {
        	if (_act == 'all' ) {a[i].checked = true;}
        	else if (_act == 'un' ) { a[i].checked = (a[i].checked) ? false : true; }
        	else { if (0 < a[i].value && a[i].checked){ v.push(a[i].value); } }
	}

	if ( 'edit' == _act ) {
        	location.href = 'admin_musicedit.php?id=' + v.join(',');
	}else if ( 'html' ==  _act){
        	if (0 == v.length){ alert('请先选择要生成的数据！'); return; }
        	location.href = 'html/admin_html_music.php?types=2&id=' + v.join(',');
	}else if ( 'shtml' ==  _act){
        	if (0 == v.length){ alert('请先选择要生成的数据！'); return; }
        	location.href = 'html/admin_html_special.php?id=' + v.join(',');
	}else if ( 'nhtml' ==  _act){
        	if (0 == v.length){ alert('请先选择要生成的数据！'); return; }
        	location.href = 'html/admin_html_news.php?id=' + v.join(',');
	}else if ( 'newsdel' ==  _act){
        	if (0 == v.length){ alert('请先选择要删除的数据！'); return; }
        	location.href = 'admin_news.php?action=newsdel&id=' + v.join(',');
	}
};

function SelectTemplets(fname){
	if(document.all){
		var posLeft = window.event.clientY-100;
		var posTop = window.event.clientX-400;
	}else{
		var posLeft = 100;
		var posTop = 100;
	}
	window.open("inc/select_templets.php?f="+fname, "popmoldWin", "scrollbars=yes,resizable=yes,statebar=no,width=600,height=400,left="+posLeft+", top="+posTop);
}

function SelectUpload(fname){
	if(document.all){
		var posLeft = window.event.clientY-100;
		var posTop = window.event.clientX-400;
	}else{
		var posLeft = 100;
		var posTop = 100;
	}
	window.open("../Include/rayfileup/?f="+fname, "popupWin", "scrollbars=yes,resizable=yes,statebar=no,width=600,height=400,left="+posLeft+", top="+posTop);
}

function create_div( _str, _msgw, _msgh ){
	//document.documentElement.style.overflow='hidden';
	//document.getElementsByTagName('body')[0].style.overflow='hidden';
	var bgObj=document.createElement('div');
	bgObj.setAttribute('id','bgDiv');
	bgObj.style.position='absolute';
	bgObj.style.top='0px';
	bgObj.style.left='0px';
	bgObj.style.background='#FFFFFF';
	bgObj.style.opacity='0.60';
	bgObj.style.filter = 'alpha(opacity=60)';
	bgObj.style.width='100%';
	bgObj.style.height=document.body.scrollHeight + 'PX';
	bgObj.style.zIndex = '10000';
	document.body.appendChild(bgObj);

	var msgObj = document.createElement('div');
	var _width = document.body.clientWidth;
	var _height = document.documentElement.clientHeight||document.body.clientHeight;
	var LeftPosition = (_width) ? (_width - _msgw)/2 : 0  ;
	var TopPosition = (_height) ? (_height - _msgh)/2 + document.documentElement.scrollTop : 0 ;
	msgObj.setAttribute('id','msgDiv');
	msgObj.setAttribute('align','center');
	msgObj.style.position = 'absolute';
	msgObj.style.border='0';
	msgObj.style.left = LeftPosition + 'px';
	msgObj.style.top  = TopPosition + 'px';
	msgObj.style.width = _msgw + 'px';
	msgObj.style.height = _msgh + 'px';
	msgObj.style.textAlign = 'center';
	msgObj.style.zIndex = '10001';
	msgObj.innerHTML= _str;
	document.body.appendChild(msgObj);
};

function close_div(){
	//document.documentElement.style.overflow='auto';
	document.body.removeChild($('bgDiv'));
	document.body.removeChild($('msgDiv'));
};

function SelectUploadaa( _id ){
	create_div( '<iframe id="ifm" src="../Include/rayfileup/?f='+_id+'" frameborder="0" width="550" height="200" scrolling="no"></iframe>', 550, 200 );
};

var sea_pop=null;
var pop_path="";
function showiframe(_scrollType, _title, _contentUrl, _width, _height){
	sea_pop=new Popup({ contentType:1, scrollType:_scrollType, isReloadOnClose:false, width:_width, height:_height });
	sea_pop.setContent("title",_title);
	sea_pop.setContent("contentUrl",_contentUrl);
	sea_pop.build();
	sea_pop.show();
	return false;
}